<template>
  <ChatView
    title="AI 恋爱大师"
    :chat-id="chatId"
    :sse-url="sseBase"
    :query-builder="buildUrl"
    :ai-avatar="aiAvatar"
    :back-to-home="true"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import ChatView from '../components/ChatView.vue'

const sseBase = 'http://localhost:8123/api/ai/love_app/chat/sse'
const chatId = ref(Math.random().toString(36).slice(2))
const aiAvatar = '/favicon.ico'

function buildUrl(message: string, cid?: string) {
  const url = new URL(sseBase)
  url.searchParams.set('message', message)
  if (cid) url.searchParams.set('chatId', cid)
  return url.toString()
}
</script>
